package com.clayecloud.common.client.controller;

import com.clayecloud.common.client.entity.ClientUserBindHouse;
import com.clayecloud.common.client.services.HouseUserService;
import com.clayecloud.common.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ClayeLink
 * @date 2021/12/31 14:53
 */
@RestController
@RequestMapping("/houseuser")
@Api(tags = "房屋模块")
public class ClientHouseController {

    @Resource
    private HouseUserService houseUserService;

    @GetMapping("/check")
    @ApiOperation("查询用户是否绑定了房屋")
    public MessageUtil checkUserBindHouse(Integer userID){
        return houseUserService.checkUserBindHouse(userID);
    }

    @GetMapping("/getUserBindAllHouse")
    @ApiOperation("获取用户绑定的全部房屋")
    public MessageUtil getUserBindAllHouse(Integer userID){
        return houseUserService.getUserBindAllHouse(userID);
    }

    @PostMapping("/bindhouse")
    @ApiOperation("绑定房屋")
    public MessageUtil userBindHouse(@RequestBody ClientUserBindHouse clientUserBindHouse){
        return houseUserService.userBindHouse(clientUserBindHouse);
    }

    @DeleteMapping("/deletehouse")
    @ApiOperation("取消绑定房屋")
    public MessageUtil deleteHouse(Integer houseID, Integer userID){
        return houseUserService.deleteByPrimaryKey(houseID,userID);
    }

}
